From 427e5348a267b7c88879b47f8d942fc3e84b30e9 Mon Sep 17 00:00:00 2001 From: Giorgos Ntemiris Date: Sat, 27 Jul 2019 20:23:25 +0200 Subject: module: add warning when import,export is detected in CJS context This will allow users to know how to change their project to support ES modules. PR-URL: https://github.com/nodejs/node/pull/28950 Reviewed-By: Bradley Farias Reviewed-By: Rich Trott Reviewed-By: Guy Bedford --- test/fixtures/es-modules/es-note-promiserej-import-2.cjs | 1 + test/fixtures/es-modules/es-note-unexpected-export-1.cjs | 2 ++ test/fixtures/es-modules/es-note-unexpected-export-2.cjs | 4 ++++ test/fixtures/es-modules/es-note-unexpected-import-1.cjs | 1 + test/fixtures/es-modules/es-note-unexpected-import-3.cjs | 1 + test/fixtures/es-modules/es-note-unexpected-import-4.cjs | 1 + test/fixtures/es-modules/es-note-unexpected-import-5.cjs | 1 + 7 files changed, 11 insertions(+) create mode 100644 test/fixtures/es-modules/es-note-promiserej-import-2.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-export-1.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-export-2.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-import-1.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-import-3.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-import-4.cjs create mode 100644 test/fixtures/es-modules/es-note-unexpected-import-5.cjs (limited to 'test/fixtures') diff --git a/test/fixtures/es-modules/es-note-promiserej-import-2.cjs b/test/fixtures/es-modules/es-note-promiserej-import-2.cjs new file mode 100644 index 0000000000..e9da32086f --- /dev/null +++ b/test/fixtures/es-modules/es-note-promiserej-import-2.cjs @@ -0,0 +1 @@ +import('valid'); diff --git a/test/fixtures/es-modules/es-note-unexpected-export-1.cjs b/test/fixtures/es-modules/es-note-unexpected-export-1.cjs new file mode 100644 index 0000000000..3e2612ed35 --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-export-1.cjs @@ -0,0 +1,2 @@ +const example = 10; +export default example; diff --git a/test/fixtures/es-modules/es-note-unexpected-export-2.cjs b/test/fixtures/es-modules/es-note-unexpected-export-2.cjs new file mode 100644 index 0000000000..637bac9616 --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-export-2.cjs @@ -0,0 +1,4 @@ +const config = 10; +export { + config +}; diff --git a/test/fixtures/es-modules/es-note-unexpected-import-1.cjs b/test/fixtures/es-modules/es-note-unexpected-import-1.cjs new file mode 100644 index 0000000000..232259b06f --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-import-1.cjs @@ -0,0 +1 @@ +import "invalid"; diff --git a/test/fixtures/es-modules/es-note-unexpected-import-3.cjs b/test/fixtures/es-modules/es-note-unexpected-import-3.cjs new file mode 100644 index 0000000000..5d2d3029e3 --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-import-3.cjs @@ -0,0 +1 @@ +import x, { y } from 'xyz' diff --git a/test/fixtures/es-modules/es-note-unexpected-import-4.cjs b/test/fixtures/es-modules/es-note-unexpected-import-4.cjs new file mode 100644 index 0000000000..5e265ba054 --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-import-4.cjs @@ -0,0 +1 @@ +import * as coordinates from 'xyz' diff --git a/test/fixtures/es-modules/es-note-unexpected-import-5.cjs b/test/fixtures/es-modules/es-note-unexpected-import-5.cjs new file mode 100644 index 0000000000..f38c3ee1a5 --- /dev/null +++ b/test/fixtures/es-modules/es-note-unexpected-import-5.cjs @@ -0,0 +1 @@ +import ('invalid') -- cgit v1.2.3