dctc 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/complie_es.js +32 -16
  2. package/package.json +2 -1
package/lib/complie_es.js CHANGED
@@ -39,22 +39,6 @@ module.exports = async function (filePath) {
39
39
  define: {
40
40
  'process.env.NODE_ENV': '"development"', // Define environment variables
41
41
  },
42
- tsconfigRaw: {
43
- compilerOptions: {
44
- target: 'es2015', // Target JavaScript version
45
- module: 'CommonJS', // Module system
46
- strict: true, // Enable strict mode
47
- moduleResolution: 'node', // Module resolution strategy
48
- esModuleInterop: true, // Enable ES module interop
49
- skipLibCheck: true, // Skip type library checks
50
- allowSyntheticDefaultImports: true, // Allow synthetic default imports
51
- sourceMap: true, // Generate source maps
52
- resolveJsonModule: true, // Allow importing JSON files
53
- lib: ['ESNext', 'DOM'], // Specify library files
54
- jsx: 'react', // JSX support
55
- },
56
- exclude: ['node_modules'], // Exclude directories
57
- },
58
42
  plugins: [
59
43
  {
60
44
  name: 'resolve-ts-dependencies',
@@ -71,7 +55,39 @@ module.exports = async function (filePath) {
71
55
  });
72
56
  },
73
57
  },
58
+ {
59
+ name: 'import-meta-shim',
60
+ setup(build) {
61
+ build.onLoad({ filter: /\.tsx?$/ }, async (args) => {
62
+ const contents = await fs.promises.readFile(args.path, 'utf8');
63
+ const transformed = contents.replace(
64
+ /import\.meta\.url/g,
65
+ 'require("url").pathToFileURL(__filename).href'
66
+ );
67
+ return {
68
+ contents: transformed,
69
+ loader: args.path.endsWith('.tsx') ? 'tsx' : 'ts'
70
+ };
71
+ });
72
+ },
73
+ },
74
74
  ],
75
+ tsconfigRaw: {
76
+ compilerOptions: {
77
+ target: 'es2015', // Target JavaScript version
78
+ module: 'CommonJS', // Module system
79
+ strict: true, // Enable strict mode
80
+ moduleResolution: 'node', // Module resolution strategy
81
+ esModuleInterop: true, // Enable ES module interop
82
+ skipLibCheck: true, // Skip type library checks
83
+ allowSyntheticDefaultImports: true, // Allow synthetic default imports
84
+ sourceMap: true, // Generate source maps
85
+ resolveJsonModule: true, // Allow importing JSON files
86
+ lib: ['ESNext', 'DOM'], // Specify library files
87
+ jsx: 'react', // JSX support
88
+ },
89
+ exclude: ['node_modules'], // Exclude directories
90
+ },
75
91
  write: false, // Prevent writing output files
76
92
  external: ['react', 'react-dom'], // Exclude external dependencies
77
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dctc",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Dynamically compile TSX/TS files and execute them.",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -44,6 +44,7 @@
44
44
  "@rollup/plugin-commonjs": "^28.0.1",
45
45
  "@rollup/plugin-node-resolve": "^15.3.0",
46
46
  "@rollup/plugin-typescript": "^12.1.0",
47
+ "@types/node": "^22.0.0",
47
48
  "chalk": "^4.1.2",
48
49
  "commander": "^13.1.0",
49
50
  "esbuild": "^0.24.2",